#include "securitywidget.h"
#include "ui_securitywidget.h"
#include <QHeaderView>
#include <iostream>
#include <QList>
#include "../CheckInfor/securityinfor.h"
#define MODELS 16
#define MODELPATHS "../conf/default/security.conf"
#include<QToolTip>

QVector<QPair<Yzty::MODECODE,Yzty::ITEMCODE>> SecurityWidget::ShowTools;
QVector<QSet<int>>  SecurityWidget::ToolMapItem;

SecurityWidget::SecurityWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SecurityWidget)
{
    ui->setupUi(this);
    Init_Ui();
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::SysShare)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::NetLogin)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::SysUpdate)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::NetPortInfor)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::AccountSec)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::PwdConfig)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::NetConfig)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::SecAudit)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::SudoConfig)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::NetFireWall)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::SysProcess)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::SysServers)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::SysKernel)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::EmailInfor)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::VirMachine)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::DefendSoft)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::UserLogin)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::BroCollect)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::BroHistory)));
    ShowTools.push_back(QPair<Yzty::MODECODE,Yzty::ITEMCODE>(int(Yzty::ToolCode::Security),int(Yzty::SecurityToolCode::BroDownload)));

    ToolMapItem[0].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::SysShare));
    ToolMapItem[1].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::NetLogin));
    ToolMapItem[2].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::SysUpdate));
    ToolMapItem[3].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::NetPortInfor));
    ToolMapItem[4].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::AccountSec));
    ToolMapItem[5].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::PwdConfig));
    ToolMapItem[6].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::NetConfig));
    ToolMapItem[7].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::SudoConfig));
    ToolMapItem[8].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::SudoConfig));
    ToolMapItem[9].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::NetFireWall));
    ToolMapItem[10].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::SysProcess));
    ToolMapItem[11].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::SysServers));
    ToolMapItem[12].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::SysKernel));
    ToolMapItem[13].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::EmailInfor));
    ToolMapItem[14].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::VirMachine));
    ToolMapItem[15].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::DefendSoft));
    ToolMapItem[16].insert(int(Yzty::ToolCode::Security)*Yzty::ToolMapItemHashCode+int(Yzty::SecurityToolCode::UserLogin));

}

SecurityWidget::~SecurityWidget()
{
    delete ui;
}

void SecurityWidget::SetCurWidget(int i){
    ui->stackedWidget->setCurrentIndex(i);
    UpdateData(i);
}

void SecurityWidget::ClearModel(Yzty::MODECODE code, Yzty::ITEMCODE tcode){
    _models[code][tcode]->clear();
    _models[code][tcode]->setHorizontalHeaderLabels(_model_labels[code][tcode]);
}

void SecurityWidget::Init_Ui(){
    QTextStream& fstream=Yzty::GetTextSteam(MODELPATHS);
    QStringList items=fstream.readAll().split('#');
    items.removeFirst();
    auto&& pstruct=Yzty::ConfigParse_Struct(items);
    Init_Config(pstruct);
}

void SecurityWidget::Init_Config(QMap<int,QVector<QPair<QString,QStringList>>>& pstruct){

    int n=pstruct.size();
    ToolMapItem.resize(n);

    _models=QVector<QList<QStandardItemModel*>>(n);
    _views=QVector<QList<QTableView*>>(n);
    _plains=QVector<QList<QPlainTextEdit*>>(n);
    _model_labels=QVector<QVector<QStringList>>(n);
    for(int i=0;i<n;i++){

        QWidget* w=new QWidget(this);
        ui->stackedWidget->addWidget(w);
        QGridLayout* layout=new QGridLayout(w);
        QTabWidget* tabw=new QTabWidget(w);
        _tabws.push_back(tabw);

        for(auto& temp:pstruct[i]){
            QWidget* tw=new QWidget(w);
            QStandardItemModel* model=new QStandardItemModel(this);
            QTableView*         view =new QTableView(tw);
            view->setMouseTracking(true);
            connect(view, &QTableView::entered, this, &SecurityWidget::doMouseTrackTip);
            QPlainTextEdit*     edit =new QPlainTextEdit(tw);

            view->setMinimumHeight(300);
            edit->setMinimumHeight(100);
            edit->setMaximumHeight(200);

            QVBoxLayout* layout_1=new QVBoxLayout();

            view->setModel(model);
            _models[i].push_back(model);
            _views[i].push_back(view);
            _plains[i].push_back(edit);
            view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
            view->setEditTriggers(QAbstractItemView::NoEditTriggers);

            model->setHorizontalHeaderLabels(temp.second);
            _model_labels[i].push_back(temp.second);

            layout_1->addWidget(view);
            layout_1->addSpacing(10);
            layout_1->addWidget(edit);
            tw->setLayout(layout_1);
            tabw->addTab(tw,temp.first);
        }

        layout->addWidget(tabw);
        w->setLayout(layout);
    }
}

void SecurityWidget::UpdateData(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    using namespace Yzty;
    ClearModel(code,tcode);
    switch (code) {
        {
            case 0:
            {
                UpdateSysShareDirInforFromCmd(code,tcode);
                break;
            }
            case 1:
            {
                UpdateNetLoginInforFromCmd(code,tcode);
                break;
            }
            case 2:
            {
                UpdateSysUpdateInforFromCmd(code,tcode);
                break;
            }
            case 3:
            {
                UpdateNetPortInforFromCmd(code,tcode);
                break;
            }
            case 4:
            {
                UpdateAccountSecInforFromCmd(code,tcode);
                break;
            }
            case 5:
            {
                UpdatePwdConfigInforFromCmd(code,tcode);
                break;
            }
            case 6:
            {
                UpdateNetConfigFromCmd(code,tcode);
                break;
            }
            case 7:
            {
                UpdateSecAuditInforFromCmd(code,tcode);
                break;
            }
            case 8:
            {
                UpdateSudoConfigInforFromCmd(code,tcode);
                break;
            }
            case 9:
            {
                UpdateNetFireWallInforFromCmd(code,tcode);
                break;
            }
            case 10:
            {
                UpdateSysProcessInforFromCmd(code,tcode);
                break;
            }
            case 11:
            {
                UpdateSysServerInforFromCmd(code,tcode);
                break;
            }
            case 12:
            {
                UpdateSysKernelInforFromCmd(code,tcode);
                break;
            }
            case 13:
            {
                UpdateEmailInforFromCmd(code,tcode);
                break;
            }
            case 14:
            {
                UpdateVirMachineFromCmd(code,tcode);
                break;
            }

            case 15:
            {
                UpdateDefendSoftFromCmd(code,tcode);
                break;
            }

            case 16:
            {
                UpdateUserLoginInfor(code,tcode);
                break;
            }

            default:
                break;
    }
    }

}

void SecurityWidget::UpdateSysShareDirInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)           //系统共享安全
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::SysShare));
    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::SysShareDirInfor* temp=dynamic_cast<const Yzty::SysShareDirInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateNetLoginInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)              //系远程登陆检查
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::NetLogin));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::NetLoginInfor* temp=dynamic_cast<const Yzty::NetLoginInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateSysUpdateInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)             //系统升级文件
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::SysUpdate));
    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::SysUpdateInfor* temp=dynamic_cast<const Yzty::SysUpdateInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateNetPortInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)               //系统开放端口
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::NetPortInfor));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::NetPortInfor* temp=dynamic_cast<const Yzty::NetPortInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateAccountSecInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)            //账户安全配置
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::AccountSec));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::AccountSecInfor* temp=dynamic_cast<const Yzty::AccountSecInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdatePwdConfigInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)             //密码策略配置
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::PwdConfig));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::PwdConfigInfor* temp=dynamic_cast<const Yzty::PwdConfigInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateNetConfigFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)                  //网络安全配置
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::NetConfig));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::NetConfig* temp=dynamic_cast<const Yzty::NetConfig*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateSecAuditInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)              //安全审计配置
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::SecAudit));
    if(infors.size()==0){
        this->_plains[code][tcode]->clear();
        this->_plains[code][tcode]->appendHtml(QString("<pre>no rules</pre>"));
        this->_plains[code][tcode]->appendHtml("</hr>");
    }
    else
        for(const Yzty::BaceInfor* infor:infors){
            const Yzty::SecAuditInfor* temp=dynamic_cast<const Yzty::SecAuditInfor*>(infor);
            QList<QStandardItem*> items;
            for(const QString& val:temp->_infors){
                QStandardItem* item=new QStandardItem(val);
                items.push_back(item);
            }

            _models[code][tcode]->appendRow(items);
        }
}


void SecurityWidget::UpdateSudoConfigInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)            //sudo策略配置
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::SudoConfig));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::SudoConfigInfor* temp=dynamic_cast<const Yzty::SudoConfigInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateNetFireWallInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)           //防火墙配置
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::NetFireWall));
    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::NetFireWallInfor* temp=dynamic_cast<const Yzty::NetFireWallInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateSysProcessInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)            //系统进程信息
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::SysProcess));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::SysProcessInfor* temp=dynamic_cast<const Yzty::SysProcessInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}
void SecurityWidget::UpdateSysServerInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)             //系统服务信息
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::SysServers));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::SysServerInfor* temp=dynamic_cast<const Yzty::SysServerInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateSysKernelInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)             //系统加载内核
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::SysKernel));
    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::SysKernelInfor* temp=dynamic_cast<const Yzty::SysKernelInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
       _models[code][tcode]->appendRow(items);
    }
}

void SecurityWidget::UpdateEmailInforFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)                 //邮件客户端
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::EmailInfor));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::EmailInfor* temp=dynamic_cast<const Yzty::EmailInfor*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
    if(infors.size() == 0) {
        _models[code][tcode]->appendRow(new QStandardItem("未发现邮件客户端"));
    }
}

void SecurityWidget::UpdateVirMachineFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)                 //虚拟机安装
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::VirMachine));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::VirMachine* temp=dynamic_cast<const Yzty::VirMachine*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
    if(infors.size() == 0) {
        _models[code][tcode]->appendRow(new QStandardItem("未发现虚拟机"));
    }
}

void SecurityWidget::UpdateDefendSoftFromCmd(Yzty::MODECODE code,Yzty::ITEMCODE tcode)                 //杀毒软件防护
{
    const QVector<Yzty::BaceInfor*>&infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::DefendSoft));

    for(const Yzty::BaceInfor* infor:infors){
        const Yzty::DefendSoft* temp=dynamic_cast<const Yzty::DefendSoft*>(infor);
        QList<QStandardItem*> items;
        for(const QString& val:temp->_infors){
            QStandardItem* item=new QStandardItem(val);
            items.push_back(item);
        }
        _models[code][tcode]->appendRow(items);
    }
    if(infors.size() == 0) {
        _models[code][tcode]->appendRow(new QStandardItem("未发现杀毒软件"));
    }
}

void SecurityWidget::UpdateUserLoginInfor(Yzty::MODECODE code,Yzty::ITEMCODE tcode){
    const QVector<Yzty::BaceInfor*>& _infors=SecurityInfor::GetInstance()->GetItemInfor(int(Yzty::SecurityToolCode::UserLogin));

    for(const Yzty::BaceInfor* temp:_infors){
        const Yzty::UserLoginInfor* infor=dynamic_cast<const Yzty::UserLoginInfor*>(temp);
        QList<QStandardItem*> items;
        for(const QString& content:infor->_infors){
            QStandardItem* t=new QStandardItem(content);
            items.push_back(t);
        }
        _models[code][tcode]->appendRow(items);
    }
}
void SecurityWidget::doMouseTrackTip(QModelIndex index)
{
    QToolTip::showText(QCursor::pos(), index.data().toString());
}
